<?php
error_reporting(E_ALL ^ E_NOTICE);
/*
TinyBrowser 1.40 - A TinyMCE file browser (C) 2008  Bryn Jones
(author website - http://www.lunarvis.com)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

// set script time out higher, to help with thumbnail generation
set_time_limit(240);

$tinybrowser = array();

// Session control and security check - to enable please uncomment
//if(isset($_GET['sessidpass'])) session_id($_GET['sessidpass']); // workaround for Flash session bug
//session_start();
//$tinybrowser['password'] = 'auth_user'; //name of session variable to check

// Random string used to secure Flash upload if session control not enabled - be sure to change!
$tinybrowser['obfuscate'] = 'awawfhaoiuhaqw32opau35g902a9023yt';

// Set default language (ISO 639-1 code)
$tinybrowser['language'] = 'en';

// Set the integration type (TinyMCE is default)
$tinybrowser['integration'] = 'fckeditor'; // Possible values: 'tinymce', 'fckeditor'



$path = 'includes/admin/tinybrowser';

function windowsToUnixPath ($str) {
	$str = preg_replace('/[a-zA-Z]:\\\/', '\\', $str);
	$str = str_replace("\\",'/', $str);
	return $str;
}

// Default is rtrim($_SERVER['DOCUMENT_ROOT'],'/') (suitable when using absolute paths, but can be set to '' if using relative paths)
$tinybrowser['docroot'] = rtrim($_SERVER['DOCUMENT_ROOT'],'/');

// Pages to split at to find the absolute server path directory
$basePages = array('tinybrowser.php', 'edit.php');
$base_url[0] = getcwd().'/';
foreach ($basePages as $value) {
	$base_url = explode($value, $base_url[0]);
}
define("T_BASE_URL", $base_url[0]);


$base_url2 = explode($path, windowsToUnixPath($_SERVER["REQUEST_URI"]));
define("S_BASE_URL", $tinybrowser['docroot'].$base_url2[0]);


$visual = explode($path, $_SERVER["REQUEST_URI"]);
define("ROOT_URL", $visual[0]);


$visual[0] = $_SERVER["REQUEST_URI"];
foreach ($basePages as $value) {
	$visual = explode($value, $visual[0]);
}
define("TB_ROOT_URL", $visual[0]);


// Set the tinybrowser var to our new converted base url to make code integration easier
$tinybrowser['docroot'] = S_BASE_URL;



// Folder permissions for Unix servers only
$tinybrowser['unixpermissions'] = 0777;

// File upload paths (set to absolute by default)
$tinybrowser['path']['image'] = 'uploaded-files/'; // Image files location - also creates a '_thumbs' subdirectory within this path to hold the image thumbnails
$tinybrowser['path']['media'] = 'uploaded-files/'; // Media files location
$tinybrowser['path']['file']  = 'uploaded-files/'; // Other files location

// File link paths - these are the paths that get passed back to TinyMCE or your application (set to equal the upload path by default)
$tinybrowser['link']['image'] = $tinybrowser['path']['image']; // Image links
$tinybrowser['link']['media'] = $tinybrowser['path']['media']; // Media links
$tinybrowser['link']['file']  = $tinybrowser['path']['file']; // Other file links

// File upload size limit (0 is unlimited)
$tinybrowser['maxsize']['image'] = 0; // Image file maximum size
$tinybrowser['maxsize']['media'] = 0; // Media file maximum size
$tinybrowser['maxsize']['file']  = 0; // Other file maximum size

// Image automatic resize on upload (0 is no resize)
$tinybrowser['imageresize']['width']  = 0;
$tinybrowser['imageresize']['height'] = 0;

// Image thumbnail source (set to 'path' by default - shouldn't need changing)
$tinybrowser['thumbsrc'] = 'path'; // Possible values: path, link

// Image thumbnail size in pixels
$tinybrowser['thumbsize'] = 196;

// Image and thumbnail quality, higher is better (1 to 99)
$tinybrowser['imagequality'] = 99; // only used when resizing or rotating
$tinybrowser['thumbquality'] = 99;

// Date format, as per php date function
$tinybrowser['dateformat'] = 'd/m/Y H:i';

// Permitted file extensions
//$tinybrowser['filetype']['image'] = '*.swf, *.dcr, *.mov, *.qt, *.mpg, *.mp3, *.mp4, *.mpeg, *.avi, *.wmv, *.wm, *.asf, *.asx, *.wmx, *.wvx, *.rm, *.ra, *.ram'; // Media file types
$tinybrowser['filetype']['image']  = '*.*'; // Other file types
$tinybrowser['filetype']['file']  = '*.*'; // Other file types
$tinybrowser['filetype']['media']  = '*.*'; // Other file types

// Prohibited file extensions
$tinybrowser['prohibited'] = array('php','php3','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','cgi', 'sh', 'py');

// Default file sort
$tinybrowser['order']['by']   = 'name'; // Possible values: name, size, type, modified
$tinybrowser['order']['type'] = 'asc'; // Possible values: asc, desc

// Default image view method
$tinybrowser['view']['image'] = 'thumb'; // Possible values: thumb, detail

// File Pagination - split results into pages (0 is none)
$tinybrowser['pagination'] = 30;

// TinyMCE dialog.css file location, relative to tinybrowser.php (can be set to absolute link)
$tinybrowser['tinymcecss'] = '../../themes/advanced/skins/default/dialog.css';

// TinyBrowser pop-up window size
$tinybrowser['window']['width']  = 770;
$tinybrowser['window']['height'] = 480;

// Assign Permissions for Upload, Edit, Delete & Folders
$tinybrowser['allowupload']  = true;
$tinybrowser['allowedit']    = true;
$tinybrowser['allowdelete']  = true;
$tinybrowser['allowfolders'] = true;

// Clean filenames on upload
$tinybrowser['cleanfilename'] = true;

// Set default action for edit page
$tinybrowser['defaultaction'] = 'rename'; // Possible values: delete, rename, move

// Set delay for file process script, only required if server response is slow
$tinybrowser['delayprocess'] = 0; // Value in seconds
global $valid_img_mime, $images_arr;
$images_arr = array('GIF', 'JPEG', 'JPG', 'BMP', "PNG");
$valid_img_mime = array(
	"jpg" => 'image/jpg',
	"jpeg" => 'image/jpg',
	"jpe" => 'image/jpg',
	"png" => 'image/png',
	"gif" => 'image/gif',
	"bmp" => 'image/bmp',
);
?>
